package com.learn.english.controller;

import com.learn.english.domain.R;
import com.learn.english.model.entity.TopBanner;
import com.learn.english.model.ro.BannerRo;
import com.learn.english.service.ITopBannerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author TISNIW
 * @version 1.0
 * @date 2025/6/22 14:29
 * @desc
 */
@RestController
@RequestMapping("/banner")
@Slf4j
public class BannerController {
    @Autowired
    private ITopBannerService topBannerService;
    /**
     * 获取顶部轮播图数据
     */
    @GetMapping("/{pageId}")
    public R<List<BannerRo>> getBanner(@PathVariable Integer pageId) {
        return R.ok(topBannerService.getTopBanner(pageId));
    }

    @PostMapping("/add")
    public R<Boolean> addBanner(@RequestBody TopBanner topBanner) {
        return R.ok(topBannerService.addTopBanner(topBanner) > 0);
    }

}
